package com.ruoyi.web.controller.mall;

import com.ruoyi.system.mc.annotations.McLogAn;
import com.ruoyi.system.mc.entity.McUserAddress;
import com.ruoyi.system.mc.entity.R;
import com.ruoyi.system.mc.service.McUserAddressService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/*
 *  @author 雨安
 *  类名： McUserAddressController
 *  创建时间：2024/5/27 用户收获地址表
 */
@RestController//返回数据 json + 字符串
@CrossOrigin//跨域请求处理
@RequestMapping("/mc/user/address/api")//访问前缀名
@Slf4j//日志
public class McUserAddressController {

    //用户地址表Service
    @Resource
    private McUserAddressService mcUserAddressService;


    /**
     * 查询用户地址表
     * @param mcUserAddress 查询条件对象
     * @return 返回查询结果集合
     */
    @PostMapping("/selectAll")
    @McLogAn(logContent = "查询用户地址信息",businessType = "查询",requestMethod = "POST")
    public R<McUserAddress>  selectUserAddress(McUserAddress mcUserAddress){
        //调用Service层方法
        return mcUserAddressService.selectUserAddress(mcUserAddress);
    }


    /**
     * 添加用户信息
     * @param mcUserAddress 添加数据对象
     * @return 返回操作结果
     */
    @PostMapping("/insert")
    @McLogAn(logContent = "添加用户地址信息",businessType = "添加",requestMethod = "POST")
    public String insertUserAddress(McUserAddress mcUserAddress){
        //调用Service层方法
        return mcUserAddressService.insertUserAddress(mcUserAddress);
    }


    /**
     * 修改用户信息表
     * @param mcUserAddress 修改对象数据 通过ID修改
     * @return 返回修改结果
     */
    @PutMapping("/update")
    @McLogAn(logContent = "修改用户地址",businessType = "修改",requestMethod = "PUT")
    public String updateUserAddressById(McUserAddress mcUserAddress){
        //调用Service层方法
        return mcUserAddressService.updateUserAddressById(mcUserAddress);
    }

    /**
     * 逻辑删除
     * @param addressId 通过ID进行逻辑删除
     * @return 返回删除结果
     */
    @PutMapping("/delete/{addressId}")
    @McLogAn(logContent = "删除用户地址",businessType = "删除",requestMethod = "PUT")
    public String deleteUserAddressById(@PathVariable("addressId") Long addressId){
        //调用Service层方法
        return mcUserAddressService.deleteUserAddressById(addressId);
    }


}
